package com.ehualu.impda;

/**
 * @Author: 吴敬超
 * @Date: 2019/9/18 13:39
 */

import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class SearchDemo {

    public static void main(String[] args) throws Exception {

        String ISUrl = "http://37.158.40.53:8080/dahuaIS/rest/picrecord/search";

        // 执行get
        // 拼接查询条件
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("q",
                "{\"startId\": 1,\"endId\": 100,\"page\":{\"pageNo\": 1,\"pageSize\":20}}"));
        String str = EntityUtils.toString(new UrlEncodedFormEntity(params));
        HttpGet httpMethod = new HttpGet(ISUrl + "?" + str);
        // 设置超时时间
        RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(60000).setConnectTimeout(60000)
                .setSocketTimeout(60000).build();
        httpMethod.setConfig(requestConfig);
        httpMethod.addHeader("Accept", "application/json;charset=UTF-8");
        httpMethod.addHeader("Content-Type", "application/json;charset=UTF-8");
        httpMethod.addHeader("authorization", "YHLTP");
        // 创建客户端，请自行进行优化的custom设置
        CloseableHttpClient client = HttpClients.custom().build();
        CloseableHttpResponse response = client.execute(httpMethod);
        HttpEntity entity = response.getEntity();
        String result = EntityUtils.toString(entity, "UTF-8");

        // 释放资源
        response.close();
        httpMethod.releaseConnection();
//{"code":100,"msg":"","data":{"pageNo":1,"pageSize":20,"rows":[{"id":1,"devChnName":"0","carNum":"豫GA2B74","carNumType":0,"carNumColor":0,"carSpeed":74,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:19:13","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/1913-531-0.jpg?streamID:3125@capTime:1463897955","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/1913-531-1.jpg?streamID:3125@capTime:1463897955","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":2,"devChnName":"0","carNum":"鲁PD0251","carNumType":0,"carNumColor":1,"carSpeed":79,"carType":2,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:19:55","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/1955-535-0.jpg?streamID:3125@capTime:1463897997","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/1955-535-1.jpg?streamID:3125@capTime:1463897997","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":3,"devChnName":"0","carNum":"鲁PUP053","carNumType":0,"carNumColor":0,"carSpeed":84,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:20:26","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2026-539-0.jpg?streamID:3125@capTime:1463898028","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2026-539-1.jpg?streamID:3125@capTime:1463898028","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":4,"devChnName":"0","carNum":"鲁P7826D","carNumType":0,"carNumColor":0,"carSpeed":87,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:20:38","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2038-542-0.jpg?streamID:3125@capTime:1463898040","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2038-542-1.jpg?streamID:3125@capTime:1463898040","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":5,"devChnName":"0","carNum":"鲁PDJ516","carNumType":0,"carNumColor":0,"carSpeed":82,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:20:43","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2043-544-0.jpg?streamID:3125@capTime:1463898045","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2043-544-1.jpg?streamID:3125@capTime:1463898045","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":6,"devChnName":"0","carNum":"鲁AH6536","carNumType":0,"carNumColor":0,"carSpeed":85,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:20:47","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2047-546-0.jpg?streamID:3125@capTime:1463898049","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2047-546-1.jpg?streamID:3125@capTime:1463898049","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":7,"devChnName":"0","carNum":"鲁P553CL","carNumType":0,"carNumColor":0,"carSpeed":93,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:20:51","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2051-548-0.jpg?streamID:3125@capTime:1463898053","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2051-548-1.jpg?streamID:3125@capTime:1463898053","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":8,"devChnName":"0","carNum":"鲁P7926D","carNumType":0,"carNumColor":0,"carSpeed":106,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:21:02","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2102-551-0.jpg?streamID:3125@capTime:1463898065","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2102-551-1.jpg?streamID:3125@capTime:1463898065","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":9,"devChnName":"0","carNum":"鲁P78075","carNumType":0,"carNumColor":0,"carSpeed":56,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:21:35","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2135-554-0.jpg?streamID:3125@capTime:1463898098","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2135-554-1.jpg?streamID:3125@capTime:1463898098","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":10,"devChnName":"0","carNum":"鲁PEQ991","carNumType":0,"carNumColor":0,"carSpeed":49,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:21:38","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2138-557-0.jpg?streamID:3125@capTime:1463898100","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2138-557-1.jpg?streamID:3125@capTime:1463898100","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":11,"devChnName":"0","carNum":"鲁PB1363","carNumType":0,"carNumColor":1,"carSpeed":63,"carType":2,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:22:00","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2200-560-0.jpg?streamID:3125@capTime:1463898122","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2200-560-1.jpg?streamID:3125@capTime:1463898122","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":12,"devChnName":"0","carNum":"鲁PGM456","carNumType":0,"carNumColor":0,"carSpeed":109,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:22:16","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2216-563-0.jpg?streamID:3125@capTime:1463898138","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2216-563-1.jpg?streamID:3125@capTime:1463898138","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":13,"devChnName":"0","carNum":"鲁PWS902","carNumType":0,"carNumColor":0,"carSpeed":72,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:22:28","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2228-565-0.jpg?streamID:3125@capTime:1463898150","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2228-565-1.jpg?streamID:3125@capTime:1463898150","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":14,"devChnName":"0","carNum":"皖K9D272","carNumType":0,"carNumColor":1,"carSpeed":77,"carType":2,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:22:32","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2232-567-0.jpg?streamID:3125@capTime:1463898154","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2232-567-1.jpg?streamID:3125@capTime:1463898154","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":15,"devChnName":"0","carNum":"鲁PAV997","carNumType":0,"carNumColor":0,"carSpeed":71,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:22:40","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2240-570-0.jpg?streamID:3125@capTime:1463898162","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2240-570-1.jpg?streamID:3125@capTime:1463898162","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":16,"devChnName":"0","carNum":"鲁PB5828","carNumType":0,"carNumColor":0,"carSpeed":81,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:23:02","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2302-573-0.jpg?streamID:3125@capTime:1463898184","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2302-573-1.jpg?streamID:3125@capTime:1463898184","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":17,"devChnName":"0","carNum":"鲁P776ZA","carNumType":0,"carNumColor":0,"carSpeed":68,"carType":1,"carColor":1,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:24:19","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2419-579-0.jpg?streamID:3125@capTime:1463898261","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2419-579-1.jpg?streamID:3125@capTime:1463898261","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":18,"devChnName":"0","carNum":"鲁P2283G","carNumType":0,"carNumColor":0,"carSpeed":51,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:24:23","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2423-581-0.jpg?streamID:3125@capTime:1463898265","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2423-581-1.jpg?streamID:3125@capTime:1463898265","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":19,"devChnName":"0","carNum":"鲁PKC927","carNumType":0,"carNumColor":0,"carSpeed":48,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:24:24","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2424-583-0.jpg?streamID:3125@capTime:1463898266","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2424-583-1.jpg?streamID:3125@capTime:1463898266","combinedPicUrl":"0","devChnId":"1000005$1$0$0"},{"id":20,"devChnName":"0","carNum":"鲁PNT239","carNumType":0,"carNumColor":0,"carSpeed":75,"carType":1,"carColor":0,"carDirect":"0","carWayCode":"1","capDate":"2016-05-22 14:24:30","carImgUrl":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2430-585-0.jpg?streamID:3125@capTime:1463898272","carImg1Url":"0","carImg2Url":"0","carImg3Url":"0","carImg4Url":"0","carImg5Url":"0","carNumPic":"http://37.158.40.81:8081/d/1000005$1$0$0/20160522/14/2430-585-1.jpg?streamID:3125@capTime:1463898272","combinedPicUrl":"0","devChnId":"1000005$1$0$0"}],"currentPage":1}}
        System.out.println(result);
    }

}
